Skip to content

fix(server): align call_tool result shapes#2830

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/mcpserver-call-tool-result-types
Open

fix(server): align call_tool result shapes#2830
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/mcpserver-call-tool-result-types

Conversation

@he-yufeng

Copy link
Copy Markdown

Summary

  • remove the unreachable raw-dict branch in MCPServer._handle_call_tool
  • align MCPServer.call_tool with the result shapes actually returned by the tool manager
  • add regression coverage for direct CallToolResult returns and unstructured content-block returns

Fixes #2695

To verify

  • uv run --frozen pytest tests\interaction\mcpserver\test_tools.py::test_tool_returning_call_tool_result_passes_through tests\interaction\mcpserver\test_tools.py::test_tool_without_output_schema_returns_unstructured_content tests\interaction\mcpserver\test_tools.py::test_call_tool_model_return_becomes_structured_content tests\server\mcpserver\test_server.py::TestServer::test_call_tool_return_annotation_lists_reachable_shapes -q
  • uv run --frozen pytest tests\interaction\test_coverage.py -q
  • uv run --frozen ruff check src\mcp\server\mcpserver\server.py tests\interaction\mcpserver\test_tools.py tests\interaction\_requirements.py tests\server\mcpserver\test_server.py
  • uv run --frozen pyright src\mcp\server\mcpserver\server.py tests\interaction\mcpserver\test_tools.py tests\interaction\_requirements.py tests\server\mcpserver\test_server.py
  • git diff --check

@he-yufeng

Copy link
Copy Markdown
Author

I checked the remaining red matrix job. It is checks / test (3.13, lowest-direct, ubuntu-latest), failing in ests/issues/test_1363_race_condition_streamable_http.py::test_race_condition_invalid_accept_headers with RuntimeError: Task group is not initialized. Make sure to use run().\n\nThis PR only narrows MCPServer.call_tool result typing and updates the corresponding focused tests; the failure is in the streamable HTTP race-condition test path and the aggregate �ll-green job is passing. I am treating it as unrelated to this change unless maintainers see a connection I missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead code path in MCPServer._handle_call_tool and incorrect call_tool return type

1 participant